﻿@{Layout = "~/Views/Shared/_Layout.cshtml";}

<h2>Bookings for course @ViewData["Course"] </h2>
<table class="Table" cellspacing="0">
    <tr>
        <th>Application code</th>
        <th>Room</th>
        <th>Time</th>
        <th></th>
    </tr>
    @{string previousCourse = "";
      foreach (var booking in ViewData.Model)
      {
            <tr onclick="location.href='@Href("~/Booking/Show/" + booking.ID)'" class="Clickable">
                <td style="width:110px;">
                    @if (previousCourse != booking.CourseInstance.Course.ID)
                    {
                        previousCourse = booking.CourseInstance.Course.ID;
                        @booking.CourseInstance.ID
                    }
                </td>
                <td style="width:90px;">
                    @booking.Room.ID
                </td>
                <td>
                    @if (booking.StartDate.Date == booking.EndDate.Date)
                    {
                        @booking.StartDate.ToShortDateString() <text> ( </text>
                        @booking.StartDate.ToShortTimeString() <text>-</text> 
                        @booking.EndDate.ToShortTimeString() <text> ) </text>
                    }
                    else
                    {
                        @booking.StartDate <text> - </text>
                        @booking.EndDate
                    }
                </td>
            </tr>
        }
    }
</table>